<template>
	<view class="position-relative overflow">
		<view class="headbg"></view>
		<view class="px-5 z-index-10 position-relative mb-4">
			<view class="d-flex d-flex-between">
				<view class="d-flex d-flex-middle">
					<image class="avatar" :src="$store.state.avatar" mode="aspectFill"></image>
					<view class="d-flex colorfff" v-if="$store.state.loginStatus">
						<text class="font32">{{$store.state.name}}</text>
					</view>
					<view class="d-flex colorfff" v-else @click="toLogin">
						<text class="font32">立即登录</text>
					</view>
				</view>
				<view class="colorfff" @click="logOut" v-if="$store.state.loginStatus">
					<text class="iconfont icon-tuichu2"></text>
					<text class="font24 ml">退出</text>
				</view>
			</view>
		</view>
		
		<view class="px-3 position-relative z-index-10">
			<view class="rounded20 p-2 bg-fff mb-3">
				<view class="d-flex d-flex-between d-flex-middle">
					<view class="d-flex d-flex-column d-flex-center d-flex-middle d-flex-item" @click="goUrl('enroll-list')">
						<image src="https://110020.oss-cn-hangzhou.aliyuncs.com/xo/workgroup-people.png" style="width: 44rpx;height: 44rpx;"></image>
						<text class="color666 font26">我的报名</text>
					</view>
					<view class="d-flex d-flex-center d-flex-middle" style="width: 150rpx;">
						<view style="height: 36rpx;width: 1px;border-left: solid 1px #ddd;"></view>
					</view>
					<view class="d-flex d-flex-column d-flex-center d-flex-middle d-flex-item" @click="goUrl('fav-list')">
						<image src="https://110020.oss-cn-hangzhou.aliyuncs.com/xo/1562157390405145.png" style="width: 44rpx;height: 44rpx;"></image>
						<text class="color666 font26">我的收藏</text>
					</view>
				</view>
			</view>
			
			<view class="rounded20 px-3 py-1 bg-fff mb-8">
				<view class="d-flex d-flex-between d-flex-middle py-2 mb-1" style="border-bottom: 1px solid rgba(0, 0, 0, .03);" @click="goUrl('enroll')">
					<text class="">报名认证</text>
					<text class="iconfont icon-arrow-right1 color999"></text>
				</view>
				<view class="d-flex d-flex-between d-flex-middle py-2 mb-1" style="border-bottom: 1px solid rgba(0, 0, 0, .03);" @click="goUrl('privacy')">
					<text class="">用户协议</text>
					<text class="iconfont icon-arrow-right1 color999"></text>
				</view>
				<view class="d-flex d-flex-between d-flex-middle py-2 mb-1" @click="goUrl('privacy')">
					<text class="">隐私政策</text>
					<text class="iconfont icon-arrow-right1 color999"></text>
				</view>
			</view>
		</view>
		
		
	</view>
</template>

<script>
	import store from '@/store/index.js';
	import { manner } from "@/util/manner.js";
	export default {
		data() {
			return {
				avatar:''
			}
		},
		methods: {
			toLogin(){
				uni.navigateTo({
					url:'/pages/login/login'
				})
			},
			goUrl(navUrl){
				if(store.state.loginStatus){
					uni.navigateTo({
						url: `/pages/${navUrl}/${navUrl}`
					})
				}else{
					manner.toLogin()
				}
			},
			logOut(){
				
				uni.showToast({
					title:'退出成功',
					duration:1000,
					complete() {
						setTimeout(()=>{
							store.commit('logout')
							uni.switchTab({
								url:'/pages/index/index'
							})
						},1000)
					}
				})
			},
			goTest(){
				uni.navigateTo({
					url:'/pages/enroll-list/enroll-list'
				})
			},
			goFav(){
				uni.navigateTo({
					url:'/pages/fav-list/fav-list'
				})
			},
			goMyStudy(){
				uni.navigateTo({
					url:'/pages/my/my'
				})
			}
		}
	}
</script>

<style>
.headbg{
	background-color:#c90101;
	position:fixed;
	top: 0;
	left: -25%;
	height: 230rpx;
	width: 150%;
	border-bottom-left-radius: 70%;
	border-bottom-right-radius: 70%;
	box-shadow: 1px 1px 32px 0px rgba(62,45,15,0.08)
}
.avatar{
	width:110rpx;
	height: 110rpx;
	border-radius: 100%;
	margin-right: 20rpx;
}
</style>
